import Vue from 'vue'
import VueRouter from 'vue-router'
// import store from '../store'
// import { MessageBox  } from 'element-ui'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('../pages/Login')
  },
  {
    path: '/',
    name: 'apply',
    component: () => import('../pages/apply'),
    children: [
      {
        path: '/apply/my',
        name: 'my',
        component: () => import('../pages/apply/my/index.vue')
      },
      {
        path: '/apply/markdown',
        name: 'markdown',
        component: () => import('../pages/apply/markdowns')
      },
      {
        path: '/apply/recommend',
        name: 'recommend',
        component: () => import('../pages/apply/recommend')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


// router.beforeEach((to, from, next) => {
//   console.log(from);
//   console.log(to);
//   // if(from.path === '/apply/markdown/' && !store.state.isMDnull) {

//   //   MessageBox.confirm('此操作将永久删除该文件, 是否继续?', '提示', {
//   //     confirmButtonText: '确定',
//   //     cancelButtonText: '取消',
//   //     type: 'warning'
//   //   }).then(() => {
//   //     next()
//   //   }).catch(() => {
//   //     confirm('是否要退出')
//   //   });
//   // } else {
//   //   next()
//   // }
//   if (from.path === '/apply/markdown/' && !store.state.isMDnull) {
//     confirm('是否要退出')
//   } else {
//     next()
//   }
  
// })

export default router
